<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/7 0007
 * Time: 11:13
 */
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, true, false, false);
$msgStr = 'after';
$msg = new AMQPMessage($msgStr,array('delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT));    //持久化必须加模式
$channel->basic_publish($msg, '', 'hello');

echo " [x] Sent $msgStr \n";

$channel->close();
$connection->close();